package com.lantosec.hmrp.modules.workflow.mapper;

import com.lantosec.hmrp.modules.workflow.vo.FlowDeploymentVO;
import com.lantosec.hmrp.modules.workflow.vo.FlowModelVO;
import com.lantosec.hmrp.modules.workflow.vo.FlowProcdefVO;
import com.lantosec.hmrp.core.kit.PageVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface RepositoryMapper {
    PageVO<FlowModelVO> queryModelList(PageVO page, @Param("modelName") String modelName, @Param("modelTypeId") String modelTypeId);

    @Select("SELECT id_,bytes_ FROM act_ge_bytearray WHERE bytes_ LIKE '<?xml version%' ")
    List<Map<String,Object>> queryAllEditorSource();

    @Update("UPDATE act_ge_bytearray SET bytes_ = #{bytes} WHERE ID_= #{id} ")
    int updateEditorSourceById(@Param("bytes") String bytes, @Param("id") String id);

    @Select("SELECT bytes_ FROM act_ge_bytearray WHERE DEPLOYMENT_ID_= #{deploymentId} AND GENERATED_ = 0 ")
    String queryEditorSource(@Param("deploymentId") String deploymentId);

    @Update("UPDATE act_ge_bytearray SET bytes_ = #{bytes} WHERE DEPLOYMENT_ID_= #{deploymentId} AND GENERATED_ = 0 ")
    int updateEditorSource(@Param("bytes") String bytes, @Param("deploymentId") String deploymentId);

    PageVO<FlowDeploymentVO> queryDeploymentList(PageVO page, @Param("name") String name, @Param("startTime") String startTime, @Param("endTime") String endTime);

    FlowProcdefVO queryProcde(@Param("deploymentId") String deploymentId);

    /**
     * 查询最新的流程Key和名称列表
     * @return
     */
    List<FlowProcdefVO> queryProcessList();
}

